package edu.ynu.se.xiecheng.achitectureclass.GreenHouse.GreenhouseService;

import edu.ynu.se.xiecheng.achitectureclass.GreenHouse.GreenhouseDao.DeviceDAO;
import edu.ynu.se.xiecheng.achitectureclass.GreenHouse.GreenhouseEntity.Device;
import edu.ynu.se.xiecheng.achitectureclass.common.service.LogicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceService extends LogicService<DeviceDAO, Device, Long> {

    public DeviceService(DeviceDAO dao) {

        super(dao);

    }

    @Autowired
    private DeviceDAO deviceDAO;
    // 通过 deviceId（String 类型）查询设备
    public Device getByDeviceId(String deviceId) {
        return deviceDAO.findByDeviceId(deviceId)
                .orElseThrow(() -> new RuntimeException("Device not found"));
    }

    // 可以添加其他自定义业务逻辑方法

}